package avicit.im.lantop.basic.useconfig.service.api;


import avicit.platform6.core.rest.msg.ResponseMsg;
import avicit.platform6.core.restclient.RestClient;
import avicit.platform6.core.restclient.RestClientUtils;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class UseConfigServiceApi {


    /**
     * 服务编码
     */
    private static final String SERVICE_CODE = "filebasicmanager";

    private static final String BASE_PATH = "/api/avicit/im/lantop/basic/useconfig/rest/UseConfigServiceRest";

    @Autowired
    private RestClient restClient;


    /**
     *初始化系统业务参数配置信息
     * @param sysId
     * @param deptId
     * @param orgId
     * @return
     */
    public List<Map<String, Object>> selectUserConfig(String sysId, String deptId, String orgId) {
        String url = BASE_PATH + "/selectUserConfig";
        Map<String,Object> map = new HashMap<>();
        map.put("sysId",sysId);
        map.put("deptId",deptId);
        map.put("orgId",orgId);
        ResponseMsg<List<Map<String, Object>>> responseMsg = restClient.doPost(SERVICE_CODE, url, map, new ParameterizedTypeReference<ResponseMsg<List<Map<String, Object>>>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }


    /**
     * 获取配置的数据
     * @param orgId
     * @param orgId1
     * @return
     */
    public Map<String, String> findConfig(String orgId, String orgId1) {
        String url = BASE_PATH + "/findConfig";
        Map<String,Object> map = new HashMap<>();
        map.put("orgId",orgId);
        map.put("orgId1",orgId1);
        ResponseMsg<Map<String, String>> responseMsg = restClient.doPost(SERVICE_CODE, url, map, new ParameterizedTypeReference<ResponseMsg<Map<String, String>>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }


    /**
     * 删除本全宗下配置数据信息
     * @param sysId
     * @param deptId
     * @param orgId
     */
    public void deleteUseData(String sysId, String deptId, String orgId) {
        String url = BASE_PATH + "/deleteUseData";
        Map<String,Object> map = new HashMap<>();
        map.put("sysId",sysId);
        map.put("deptId",deptId);
        map.put("orgId",orgId);
        ResponseMsg responseMsg = restClient.doPost(SERVICE_CODE, url, map, new ParameterizedTypeReference<ResponseMsg>() {
        });
    }


    /**
     * 新增利用配置数据信息
     * @param sysId
     * @param orgId
     * @param deptId
     * @param useType
     * @param o
     * @param o1
     * @param o2
     * @param appointmentArsDays
     */
    public void createArchivalMessage(String sysId, String orgId, String deptId, String useType, Object o, Object o1, Object o2, String appointmentArsDays) {
        String url = BASE_PATH + "/createArchivalMessage";
        Map<String,Object> map = new HashMap<>();
        map.put("sysId",sysId);
        map.put("orgId",orgId);
        map.put("deptId",deptId);
        map.put("useType",useType);
        map.put("o",o);
        map.put("o1",o1);
        map.put("o2",o2);
        map.put("appointmentArsDays",appointmentArsDays);
        ResponseMsg responseMsg = restClient.doPost(SERVICE_CODE, url, map, new ParameterizedTypeReference<ResponseMsg>() {
        });
    }
}
